Skip to content

Improve deepobject unmarshalling to support nullable.Nullable and encode.TextUnmarshaler#45

Merged
mromaszewicz merged 5 commits intooapi-codegen:mainfrom
j-waters:improve-deepobject-unmarshalling
Mar 30, 2026
Merged

Improve deepobject unmarshalling to support nullable.Nullable and encode.TextUnmarshaler#45
mromaszewicz merged 5 commits intooapi-codegen:mainfrom
j-waters:improve-deepobject-unmarshalling

Conversation

@j-waters
Copy link
Copy Markdown
Contributor

@j-waters j-waters commented Jun 7, 2024

Fixes #44.

This adjusts deep object unmarshalling to support types that implement encoding.TextUnmarshaler (which fixes the issue with with unmarshalling uuid.UUID, and is an interface that is commonly implemented by other types). I'm aware that the Binder interface exists however most types from common libraries don't/won't implement it.

It also adjust deep object marshalling to support nil types, marshalling them as field=null rather than field=.

Finally, it adds custom unmarshalling for the nullable.Nullable type. I'm not 100% happy with how I've done this, with the nullableLike interface, however because nullable.Nullable is generic it's tricky to use casting/reflection to determine the type.

@j-waters j-waters requested a review from a team as a code owner June 7, 2024 10:24
mromaszewicz and others added 2 commits March 27, 2026 11:10
…marshalling

# Conflicts:
#	deepobject.go
#	deepobject_test.go
Remove nullable.Nullable deep object support (moved to separate repo).
Move TextUnmarshaler check into case reflect.Struct after the legacy
Date/time.Time handlers, so it catches types like uuid.UUID without
intercepting time.Time date-only fallback parsing. Add early returns
to the Date and time.Time blocks which previously fell through.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mromaszewicz
Copy link
Copy Markdown
Member

This is an old PR, sorry for getting to it after such a long time. I'm going to edit your PR to remove the nullable stuff, since it's no longer relevant, and resolve the conflicts and clean up the rest. This will amount to only adding the marshaler path.

@mromaszewicz
Copy link
Copy Markdown
Member

Oh, bummer, the repo is archived, I can't do that.

@j-waters
Copy link
Copy Markdown
Contributor Author

Hi, thank you for getting to this - apologies, I'd archived all my non-active public repos. I've unarchived it now

@mromaszewicz mromaszewicz added the enhancement New feature or request label Mar 30, 2026
@mromaszewicz mromaszewicz merged commit 5ea8c65 into oapi-codegen:main Mar 30, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deep object's don't support nullable.Nullable or more complex types like uuid.UUID

2 participants